package org.ricks.condition1.test;

import org.ricks.condition1.entity.Task;
import org.ricks.condition1.event.TaskCompletedEvent;
import org.ricks.ioc.anno.Bean;
import org.ricks.ioc.event.anno.EventReceiver;
import org.ricks.orm.OrmContext;

@Bean
public class TaskController {

    @EventReceiver
    public void doTaskCompleted (TaskCompletedEvent taskCompletedEvent) {

        System.err.println("触发了任务完成，" + taskCompletedEvent.task().getTaskId());

        Task task = taskCompletedEvent.task();
        task.setStatus(Task.TaskStatus.COMPLETED);
//        OrmContext.me().update(task);
    }

//    @EventReceiver
//    public void doACompleted (A taskCompletedEvent) {
//
//        System.err.println("触发了任务完成，" + taskCompletedEvent.getTask().getTaskId());
//
//        Task task = taskCompletedEvent.getTask();
//        task.setStatus(Task.TaskStatus.COMPLETED);
//        OrmContext.me().update(task);
//    }
}
